library(maps)library(viridis)library(tidyverse)library(leaflet)library(sf)library(tigris)# Load the USArrests datasetdata(USArrests)# Prepare the data for leafletarrests_data <- USArrests %>%rownames_to_column(var ="state") %>%mutate(state =tolower(state))# Load the US states map dataus_states_map <-map_data("state")# Define color palettecolor_pal <-colorBin(viridis_pal()(5), domain = arrests_data$Murder, bins =5)# Join the US states map data with the arrests dataus_states_map_data <- us_states_map %>%left_join(arrests_data, by =c("region"="state"))# Load the US states shapefile dataus_states_shapefile <-states(class ="sf", resolution ="20m") %>%st_transform(4326) %>%mutate(state =tolower(NAME))# Join the US states shapefile data with the arrests dataus_states_map_data <- us_states_shapefile %>%left_join(arrests_data, by =c("state"="state"))